/*
 *  Copyright 2009 Lucas Nazário dos Santos
 *  
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  
 *      http://www.apache.org/licenses/LICENSE-2.0
 *  
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package net.sourceforge.retriever.feedback;

/**
 * CrawlerFeedback implementation in which the output goes to the console.
 */
public class ConsoleFeedback implements Feedback {


	/**
	 * Prints out the error message, together with the the exception's
	 * stack trace.
	 * 
	 * @param url States that the error message is associated with a URL.
	 * @param message The message to be printed.
	 * @param caught The exception with the stack trace to be printed.
	 */
	public synchronized void error(final String url, final String message, final Throwable caught) {
		System.out.printf("ERROR MESSAGE: %s\n", message);
		if (caught != null) {
			caught.printStackTrace();
			System.out.println();
		}
	}

	/**
	 * Prints out the informative message.
	 * 
	 * @param url States that the warning message is associated with a URL.
	 * @param message The message to be printed.
	 */
	public synchronized void info(final String url, final String message) {
		System.out.printf("INFO MESSAGE: %s\n", message);
	}

	/**
	 * Prints out the warning message.
	 * 
	 * @param url States that the info message is associated with a URL.
	 * @param message The message to be printed.
	 */
	public synchronized void warning(final String url, final String message) {
		System.out.printf("WARNING MESSAGE: %s\n", message);
	}
}